package _18_lianxi;

import java.util.Comparator;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;

public class Student {

	public static void main(String[] args) {
		@SuppressWarnings("unchecked")
		SortedMap students = new TreeMap();
		Student1 s1 = new Student1(1001, "张三1", 12, "河北");
		Student1 s2 = new Student1(1002, "张三2", 12, "河北");
		Student1 s3 = new Student1(1003, "张三3", 12, "河北");
		Student1 s4 = new Student1(1004, "张三4", 12, "河北");
		Student1 s5 = new Student1(1005, "张三5", 12, "河北");
		Student1 s6 = new Student1(1006, "张三6", 12, "河北");
		Student1 s7 = new Student1(1007, "张三7", 12, "河北");
		Student1 s8 = new Student1(1008, "张三8", 12, "河北");
		Student1 s9 = new Student1(1009, "张三9", 12, "河北");
		Student1 s10 = new Student1(10010, "张三10", 12, "河北");
		students.put(21345, s1);
		students.put(12345, s2);
		students.put(34567, s3);
		students.put(43545, s4);
		students.put(48645, s5);
		students.put(46864, s6);
		students.put(13532, s7);
		students.put(53412, s8);
		students.put(53123, s9);
		students.put(51351, s10);

		Set keys = students.entrySet();
		for (Object object : keys) {
			System.out.println(object);
		}
	}

}

//new Comparator() {
//
//	@Override
//	public int compare(Object o1, Object o2) {
//		int id1 = ((Student1) o1).id;
//		int id2 = ((Student1) o2).id;
//		if (id1 == id2) {
//			return 0;
//		} else if (id1 < id2) {
//			return -1;
//		} else {
//			return 1;
//		}
//	}
//
//}
class Student1 {
	int id;
	String name;
	int age;
	String address;

	public Student1(int id, String name, int age, String address) {
		super();
		this.id = id;
		this.name = name;
		this.age = age;
		this.address = address;
	}

	@Override
	public String toString() {
		return " 编号 : " + id + ", 姓名= " + name + ", 年龄= " + age + ", 地址= " + address + "]";
	}
}